
package com.qdu.service.impl;

import com.qdu.dao.AdminDao;
import com.qdu.dao.PublicActivityDao;
import com.qdu.dao.UsersDao;
import com.qdu.dao.impl.AdminDaoImpl;
import com.qdu.dao.impl.PublicActivityDaoImpl;
import com.qdu.dao.impl.UsersDaoImpl;
import com.qdu.entity.Admin;
import com.qdu.entity.PublicActivity;
import com.qdu.entity.Users;
import com.qdu.service.AdminService;
import java.util.List;

/**
 *
 * @author 24959
 */
public class AdminServiceImpl implements AdminService{

    AdminDao adminDao=new AdminDaoImpl(); 
    UsersDao usersDao=new UsersDaoImpl();
    PublicActivityDao publicDao=new PublicActivityDaoImpl();
    
    
    @Override
    public Admin validateLogin(int Ano, String Apwd) {
        Admin a=adminDao.getOneByAno(Ano);
        if(null!=a&&a.getApwd().equals(Apwd)){
            return  a;
        }else{
            return null;
        }
    }
    
    @Override
    public int addNewAdmin(Admin a) {
        Admin admin=adminDao.getOneByAno(a.getAno());
        if(null==admin){
            return adminDao.insert(a);
        }else{
            return -1;
        }
    }

    @Override
    public int modifyAdminPassWord(Admin a) {
        return adminDao.modifyApwd(a);
    }

    @Override
    public int deleteAdmin(int Ano) {
        return adminDao.deleteByAno(Ano);
    }

    @Override
    public int deleteUser(int Uno) {
        return usersDao.deleteByUno(Uno);
    }

    @Override
    public int deletePublic(int Pno) {
        return publicDao.deleteByPno(Pno);
    }

    @Override
    public List<Admin> findAllAdmin() {
        return adminDao.getAll();
    }

    @Override
    public List<Users> findAllUsers() {
        return usersDao.getAll();
    }

    @Override
    public List<PublicActivity> findAllPublicActivitys() {
        return publicDao.getAll();
    }

    @Override
    public Admin getAdminByAno(int Ano) {
        
        return adminDao.getOneByAno(Ano);
    }

    @Override
    public Users getOneUserByUno(int Uno) {
        return usersDao.getOneByUno(Uno);
    }
    
}
